import dynamic from 'dva/dynamic';

// wrapper of dynamic
const dynamicWrapper = (app, models, component) => dynamic({
  app,
  models: () => models.map(m => import(`../models/${m}.js`)),
  component,
});

// nav data
export const getNavData = app => [
  {
    component: dynamicWrapper(app, ['user'], () => import('../layouts/MapLayout')),
    layout: 'MapLayout',
    name: '首页', // for breadcrumb
    path: '/map',
    children: [
      {
        name: '数据面板',
          icon: 'pie-chart',
        path: 'map/console',
        component: dynamicWrapper(app, ['rule'], () => import('../routes/Map/DataPanel')),
      },
      {
        name: '地图',
          icon: 'pie-chart',
        path: 'map/map',
        component: dynamicWrapper(app, ['rule'], () => import('../routes/Map/MapPanel')),
      },
      {
        name: '管控', icon: 'pie-chart',
        path: 'map/console2',
        component: dynamicWrapper(app, ['rule'], () => import('../routes/Map/DataPanel')),
      },
      {
        name: '上下刊', icon: 'pie-chart',
        path: 'map/console3',
        component: dynamicWrapper(app, ['rule'], () => import('../routes/Map/DataPanel')),
      },
      {
        name: '巡查', icon: 'pie-chart',
        path: 'map/console4',
        component: dynamicWrapper(app, ['rule'], () => import('../routes/Map/DataPanel')),
      },
      {
        name: '工程', icon: 'pie-chart',
        path: 'map/console5',
        component: dynamicWrapper(app, ['rule'], () => import('../routes/Map/DataPanel')),
      },
    ],
  },
  {
    component: dynamicWrapper(app, ['user'], () => import('../layouts/LightBoxLayout')),
    layout: 'LightBoxLayout',
    name: '首页', // for breadcrumb
    path: '/lightbox',
    children: [
      {
        name: 'lightbox',
          icon: 'pie-chart',
        path: 'lightbox/console3',
        component: dynamicWrapper(app, ['rule'], () => import('../routes/Map/DataPanel')),
      },
    ],
  },
];

